package com.meevle.business
{
	import com.adobe.cairngorm.business.ServiceLocator;
	import com.meevle.vo.LoginVO;
	import com.meevle.vo.RegistrationVO;
	import com.meevle.vo.UserVO;
	
	import mx.rpc.IResponder;
	
	public class UserDelegate 
	{
		private var responder:IResponder;
		private var service:Object;
		
		public function UserDelegate(responder:IResponder)
		{
			this.responder = responder;
			this.service = ServiceLocator.getInstance().getRemoteObject("userDelegateService");
		}

		public function login(loginAttempt:LoginVO) : void {
			var call:Object = service.login(loginAttempt.username, loginAttempt.password);
			call.addResponder(responder);
		}
		
		public function getUser(user:UserVO) : void {
			var call:Object = service.getUser(user);
			call.addResponder(responder);
		}
		
		public function register(registrationAttempt:RegistrationVO) : void {
			var user:UserVO = new UserVO();
			user.username = registrationAttempt.username;
			var password:String = registrationAttempt.password;
			
			var call:Object = service.createUser(user, password);
			call.addResponder(responder);
		}
	}
}